package com.ocean.system.service.impl;

import java.util.List;

import com.ocean.common.core.domain.entity.SysUser;
import com.ocean.common.utils.ShiroUtils;
import com.ocean.system.domain.SysHistoryDaysDo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ocean.system.mapper.SysHistoryDaysMapper;
import com.ocean.system.service.ISysHistoryDaysService;
import com.ocean.common.core.text.Convert;

/**
 * @Author: FuGui Wang
 * @Description: 未更新产品天数维护Service业务层处理
 * @Date 2023/2/17
 * @Version V1.1.0
 */
@Service
public class SysHistoryDaysServiceImpl implements ISysHistoryDaysService 
{
    @Autowired
    private SysHistoryDaysMapper sysHistoryDaysMapper;

    /**
     * 查询未更新产品天数维护
     * 
     * @param id 未更新产品天数维护主键
     * @return 未更新产品天数维护
     */
    @Override
    public SysHistoryDaysDo selectSysHistoryDaysById(Integer id)
    {
        return sysHistoryDaysMapper.selectSysHistoryDaysById(id);
    }

    /**
     * 查询未更新产品天数维护列表
     * 
     * @param sysHistoryDaysDo 未更新产品天数维护
     * @return 未更新产品天数维护
     */
    @Override
    public List<SysHistoryDaysDo> selectSysHistoryDaysList(SysHistoryDaysDo sysHistoryDaysDo)
    {
        return sysHistoryDaysMapper.selectSysHistoryDaysList(sysHistoryDaysDo);
    }

    /**
     * 新增未更新产品天数维护
     * 
     * @param sysHistoryDaysDo 未更新产品天数维护
     * @return 结果
     */
    @Override
    public int insertSysHistoryDays(SysHistoryDaysDo sysHistoryDaysDo)
    {
        SysUser sysUser = ShiroUtils.getSysUser();
        if(StringUtils.isNotBlank(sysUser.getLoginName())){
            sysHistoryDaysDo.setCreateBy(ShiroUtils.getLoginName());
        }
        if(StringUtils.isNotBlank(sysUser.getUserName())){
            sysHistoryDaysDo.setCreateName(sysUser.getUserName());
        }
        return sysHistoryDaysMapper.insertSysHistoryDays(sysHistoryDaysDo);
    }

    /**
     * 修改未更新产品天数维护
     * 
     * @param sysHistoryDaysDo 未更新产品天数维护
     * @return 结果
     */
    @Override
    public int updateSysHistoryDays(SysHistoryDaysDo sysHistoryDaysDo)
    {
        // 获取用户缓存信息
        SysUser sysUser = ShiroUtils.getSysUser();
        if(StringUtils.isNotBlank(sysUser.getLoginName())){
            sysHistoryDaysDo.setUpdateBy(ShiroUtils.getLoginName());
        }
        if(StringUtils.isNotBlank(sysUser.getUserName())){
            sysHistoryDaysDo.setUpdateName(sysUser.getUserName());
        }
        return sysHistoryDaysMapper.updateSysHistoryDays(sysHistoryDaysDo);
    }

    /**
     * 批量删除未更新产品天数维护
     * 
     * @param ids 需要删除的未更新产品天数维护主键
     * @return 结果
     */
    @Override
    public int deleteSysHistoryDaysByIds(String ids)
    {
        return sysHistoryDaysMapper.deleteSysHistoryDaysByIds(Convert.toIntArray(ids));
    }
}
